﻿using Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IRepository
{
   public interface ISalesOrderRepository
   {
        //查询销售订单新增客户名称绑定下拉框
        Task<List<CustomerSelectDto>> GetCustomerSelectList();

        // 新增：根据客户ID查询详情
        Task<WMSBasicCustomer> GetCustomerDetailById(int customerId);


        //查询销售订单销售部门
        Task<List<OrganizationTreeDto>> GetOrganizationTreeAsync();


        // 按部门ID查询用户列表
        Task<List<SysOrgUserManagement>> GetUsersByDeptIdAsync(int deptId);
        // 按用户ID查询用户信息
        Task<SysOrgUserManagement> GetUserByIdAsync(int userId);


        // 按部门ID查询部门信息
        Task<SysOrgOrganizations> GetOrganizationByIdAsync(int? orgId);


        //初始化查询所以销售负责人你
        Task<List<SysOrgUserManagement>> GetAllPersonInChargeAsync();

        //销售部门搜索框
        Task<List<OrganizationTreeDto>> GetOrganizationTreeAsync2(string keyword);


        //销售订单新增销售货品明细添加分页
        Task<List<ProductInformationEntity2>> GetAllProductInformationAsync(
string product_code = null,
string product_name = null,
string unit = null);


        // 参数改为主表实体 + 明细列表
        Task<int> AddSalesOrderWithDetailsAsync(WMSOrderSalesOrder order, List<WMSOrderSalesOrderDetails> detailsList);


        //销售订单页面分页显示
        Task<List<WMSOrderSalesOrder2>> GetAllWMSOrderSalesOrder2Async(
string sales_order_no = null,
string document_status = null,
string customer_name = null,
 DateTime? sales_date = null);


        //根据销售单号查询销售订单详情

        Task<WMSOrderSalesOrder2> GetSalesOrderDetailByNo(string saleOrderNo);



        // 逻辑删除（批量），返回受影响的行数
        Task<int> LogicalDeleteBatch(List<string> saleOrderNos);
        // 逻辑删除（单条），返回受影响的行数
        Task<int> LogicalDeleteSingle(string saleOrderNo);




        /// <summary>
        /// 异步批量审核销售订单
        /// </summary>
        Task<int> BatchAuditAsync(List<int> orderIds, string auditResult, string auditOpinion, string reviewer);

        /// <summary>
        /// 异步批量撤销销售订单
        /// </summary>
        Task<int> BatchRevokeAsync(List<int> orderIds);

        /// <summary>
        /// 异步校验可审核的订单ID
        /// </summary>
        Task<List<int>> GetValidAuditOrderIdsAsync(List<int> orderIds);

        /// <summary>
        /// 异步校验可撤销的订单ID
        /// </summary>
        Task<List<int>> GetValidRevokeOrderIdsAsync(List<int> orderIds);




        /// <summary>
        /// 单条撤销方法
        /// </summary>
        /// <param name="saleOrderId"></param>
        /// <returns></returns>
        Task<int> LogicalRevokeSingle(int saleOrderId);



        //查询人员信息
        Task<IEnumerable<dynamic>> GetUsersByOrgIdAsync(int orgId, string keyword = "");
    }
}
